#include <iostream>

using std::cout;
using std::endl;


//this指针：代表的是当前对象
//this指针：作为成员函数的第一个隐含参数而存在的

class Point
{
public:
    Point(int ix = 0, int iy = 0)
    : _ix(ix)
    , _iy(iy)
    {
        cout << "Point(int,int)" << endl;
    }

    Point(const Point & rhs)
    : _ix(rhs._ix)
    , _iy(rhs._iy)
    {
        cout << "Point(const Point&)" << endl;
        cout << this->_ix << endl;
    }

    ~Point() {
        cout << "~Point()" << endl;
    }

    //this指针在编译时会自动添加
    void print(/*   Point *  const this     */) 
    {
        //this = 0x1000;//error, 不能改变指向
        cout << "(" << this->_ix 
             << "," << this->_iy << ")" << endl;
    }

private:
    int _ix;
    int _iy;
};


int test0()
{
    Point pt1(10, 11);
    Point pt2(20, 21);

    cout << "pt1:";
    pt1.print();// pt1.print(&pt1)  =>  Point::print(&pt1)
    //&pt1;

    cout << "pt2:";
    pt2.print();

    Point * p1 = new Point(1, 2);
    p1->print();// Point::print(p1);

    return 0;
}

int main()
{
    test0();
    return 0;
}

